Skip to content

Conversation

moh1434
Copy link

@moh1434 moh1434 commented Feb 22, 2023

This snippet make setup typescript script with props and emits.

<template>
  <div>

  </div>
</template>

<script setup lang="ts">
export interface Props {
  user?: string
}
const props = withDefaults(defineProps<Props>(), {
  user: 'foo'
})

const emits = defineEmits<{
  (e: 'update:user', newValue: string): void
}>()
const onClick = () => emits('update:user', 'bar');

//in parent component:
//	v-model:user="userParentVariable"
//OR:
//	:user="userParentVariable" @update:user="userParentVariable = event"

</script>

<style scoped>

</style>

@moh1434 moh1434 closed this Sep 5, 2023
@moh1434 moh1434 reopened this Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant